home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / gnuchess.arc / gnuchess.h < prev    next >
C/C++ Source or Header  |  1992-01-16  |  7KB  |  283 lines

  1. /*
  2.   gnuchess.h - Header file for GNU CHESS
  3.  
  4.   Revision: 1990-04-18
  5.  
  6.   Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  7.  
  8.   This file is part of CHESS.
  9.  
  10.   CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  11.   WARRANTY.  No author or distributor accepts responsibility to anyone for
  12.   the consequences of using it or for whether it serves any particular
  13.   purpose or works at all, unless he says so in writing.  Refer to the CHESS
  14.   General Public License for full details.
  15.  
  16.   Everyone is granted permission to copy, modify and redistribute CHESS, but
  17.   only under the conditions described in the CHESS General Public License.
  18.   A copy of this license is supposed to have been given to you along with
  19.   CHESS so you can know your rights and responsibilities.  It should be in a
  20.   file named COPYING.  Among other things, the copyright notice and this
  21.   notice must be preserved on all copies.
  22. */
  23.  
  24. #include <stdio.h>
  25. /* <stdio.h */
  26. extern int fclose (FILE *);
  27. extern int fscanf (FILE *, const char *, ...);
  28. extern int fprintf (FILE *, const char *, ...);
  29. extern int fflush (FILE *);
  30. #define SEEK_SET 0
  31. #define SEEK_END 2
  32.  
  33. #if !defined(__STDC__) || !defined(MSDOS)
  34. #define const
  35. #endif
  36.  
  37. #ifndef __GNUC__
  38. #define inline
  39. #endif
  40.  
  41. /*
  42.   ttblsz must be a power of 2.
  43.   Setting ttblsz 0 removes the transposition tables.
  44. */
  45. # define    ttblsz 0
  46. # if !defined(ttblsz)
  47. #ifdef MSDOS
  48. #define ttblsz (1 << 11)
  49. #else
  50. #define ttblsz (1 << 16)
  51. #define huge
  52. #endif /* MSODS */
  53. # endif
  54.  
  55. #define maxdepth 30
  56. #define white 0
  57. #define black 1
  58. #define neutral 2
  59. #define no_piece 0
  60. #define pawn 1
  61. #define knight 2
  62. #define bishop 3
  63. #define rook 4
  64. #define queen 5
  65. #define king 6
  66. #define bpawn 7
  67. #define pmask 0x0007
  68. #define promote 0x0008
  69. #define cstlmask 0x0010
  70. #define epmask 0x0020
  71. #define exact 0x0040
  72. #define pwnthrt 0x0080
  73. #define check 0x0100
  74. #define capture 0x0200
  75. #define draw 0x0400
  76. #define maxdepth 30
  77. #define false 0
  78. #define true 1
  79. /* #define absv(x) ((x) < 0 ? -(x) : (x)) */
  80.  
  81. struct leaf
  82. {
  83.   short f, t, score, reply;
  84.   unsigned short flags;
  85. };
  86. struct GameRec
  87. {
  88.   unsigned short gmove;
  89.   short score, depth, time, piece, color;
  90.   long nodes;
  91. };
  92. struct TimeControlRec
  93. {
  94.   short moves[2];
  95.   long clock[2];
  96. };
  97. struct BookEntry
  98. {
  99.   struct BookEntry *next;
  100.   unsigned short *mv;
  101. };
  102.  
  103. struct flags
  104. {
  105.   short mate;        /* the game is over */
  106.   short post;        /* show principle variation */
  107.   short quit;        /* quit/exit gnuchess */
  108.   short reverse;    /* reverse board display */
  109.   short bothsides;    /* computer plays both sides */
  110.   short hash;        /* enable/disable transposition table */
  111.   short force;        /* enter moves */
  112.   short easy;        /* disable thinking on opponents time */
  113.   short beep;        /* enable/disable beep */
  114.   short timeout;    /* time to make a move */
  115.   short rcptr;        /* enable/disable recapture heuristics */
  116. };
  117.  
  118. extern const short Stboard[64];
  119. extern const short Stcolor[64];
  120. extern const short _near otherside[3];
  121. extern long     _near NodeCnt, 
  122.     _near ETnodes, 
  123.     _near EvalNodes, 
  124.     _near HashCnt, 
  125.     _near HashCol;
  126. extern long     _near ResponseTime, 
  127.     _near ExtraTime, 
  128.     _near Level, 
  129.     _near et, 
  130.     _near et0, 
  131.     _near time0, 
  132.     _near ft;
  133. extern short     _near GameCnt, 
  134.     _near Game50;
  135. extern short _near PieceList[2][16], 
  136.     _near PawnCnt[2][8];
  137. extern short     _near Sdepth, 
  138.     _near MaxSearchDepth;
  139. extern short     _near TCflag, 
  140.     _near TCmoves, 
  141.     _near TCminutes, 
  142.     _near OperatorTime;
  143. extern short _near TrPnt[maxdepth];
  144. extern short     _near dither, 
  145.         _near player;
  146. extern short     _near opponent, 
  147.     _near computer, 
  148.     _near Awindow, 
  149.     _near Bwindow, 
  150.     _near INCscore;
  151. extern short _near board[64], 
  152.     _near color[64];
  153. extern short _near castld[2], 
  154.     _near Mvboard[64];
  155. extern short svalue[64];
  156. extern short     _near xwndw, 
  157.         _near epsquare, 
  158.         _near contempt;
  159. extern struct BookEntry *_near Book;
  160. extern struct GameRec GameList[512];
  161. extern struct TimeControlRec _near TimeControl;
  162. extern struct flags _near flag;
  163. extern struct leaf Tree[2000];
  164. extern struct leaf *_near root;
  165. extern unsigned short _near hint, 
  166.     _near PrVar[maxdepth];
  167.  
  168. #define distance(a,b) distdata[a][b]
  169. #define row(a) ((a) >> 3)
  170. #define column(a) ((a) & 7)
  171. #define locn(a,b) (((a) << 3) | b)
  172. extern short distdata[64][64];
  173.  
  174. /* gnuchess.c external functions */
  175. extern void NewGame (void);
  176. /* book.c */
  177. extern int parse (FILE * fd, short unsigned int *mv);
  178. extern void GetOpenings (void);
  179. extern void OpeningBook (unsigned short int *hint);
  180. /* search.c */
  181. extern void repetition (short int *cnt);
  182. extern void SelectMove (short int side, short int iop);
  183. extern int search (short int side,
  184.            short int ply,
  185.            short int depth,
  186.            short int alpha,
  187.            short int beta,
  188.            short unsigned int *bstline,
  189.            short int *rpt);
  190. /* tran.c */
  191. extern void ZeroRPT (void);
  192. #if ttblsz
  193. extern int ProbeTTable (short int side,
  194.             short int depth,
  195.             short int *alpha,
  196.             short int *beta,
  197.             short int *score);
  198. extern void PutInTTable (short int side,
  199.              short int score,
  200.              short int depth,
  201.              short int alpha,
  202.              short int beta,
  203.              short unsigned int mv);
  204. extern void ZeroTTable (void);
  205. #ifdef HASHFILE
  206. extern int ProbeFTable (short int side,
  207.             short int depth,
  208.             short int *alpha,
  209.             short int *beta,
  210.             short int *score);
  211. extern void PutInFTable (short int side,
  212.              short int score,
  213.              short int depth,
  214.              short int alpha,
  215.              short int beta,
  216.              short unsigned int f,
  217.              short unsigned int t);
  218. #endif /* HASHFILE */
  219. #endif /* ttblsz */
  220. /* move.c */
  221. extern void Initialize_moves (void);
  222. extern void MoveList (short int side, short int ply);
  223. extern void CaptureList (short int side, short int ply);
  224. extern int castle (short int side, short int kf, short int kt, short int iop);
  225. extern void MakeMove (short int side,
  226.               struct leaf * node,
  227.               short int *tempb,
  228.               short int *tempc,
  229.               short int *tempsf,
  230.               short int *tempst,
  231.               short int *INCscore);
  232. extern void UnmakeMove (short int side,
  233.             struct leaf * node,
  234.             short int *tempb,
  235.             short int *tempc,
  236.             short int *tempsf,
  237.             short int *tempst);
  238. extern void InitializeStats (void);
  239. /* eval.c */
  240. extern int SqAtakd (short int sq, short int side);
  241. extern int evaluate (short int side,
  242.              short int ply,
  243.              short int alpha,
  244.              short int beta,
  245.              short int INCscore,
  246.              short int *slk,
  247.              short int *InChk);
  248. extern void ScoreLoneKing (short int side, short int *score);
  249. extern void ScorePosition (short int side, short int *score);
  250. extern void ExaminePosition (void);
  251. extern void UpdateWeights (void);
  252.  
  253. /* *dsp.c external functions */
  254. extern void Initialize (void);
  255. extern void InputCommand (void);
  256. extern void ExitChess (void);
  257. extern void ClrScreen (void);
  258. extern void SetTimeControl (void);
  259. extern void SelectLevel (void);
  260. extern void UpdateDisplay (short int f,
  261.                short int t,
  262.                short int flag,
  263.                short int iscastle);
  264. extern void ElapsedTime (short int iop);
  265. extern void ShowSidetomove (void);
  266. extern void SearchStartStuff (short int side);
  267. extern void ShowDepth (char ch);
  268. extern void ShowResults (short int score,
  269.              short unsigned int *bstline,
  270.              char ch);
  271. extern void algbr (short int f, short int t, short int flag);
  272. extern void OutputMove (void);
  273. extern void ShowCurrentMove (short int pnt, short int f, short int t);
  274. extern void ListGame (void);
  275. extern void ShowMessage (char *s);
  276. extern void ClrScreen (void);
  277. extern void gotoXY (short int x, short int y);
  278. extern void ClrEoln (void);
  279. extern void DrawPiece (short int sq);
  280. extern void UpdateClocks (void);
  281.  
  282.  
  283.